<?php

namespace App\Admin\Grid\Displayers;

use Dcat\Admin\Admin;
use Dcat\Admin\Grid\Displayers\AbstractDisplayer;
use Dcat\Admin\Grid\Displayers\Editable;
use Dcat\Admin\Support\Helper;
use Illuminate\Support\Facades\Storage;

class  NewAudio extends Editable
{

    public function display($displayText = null)
    {

        $displayText = $displayText ?? $this->value;
        if (!$displayText) return '';
        $fileUrl = str_starts_with($displayText , 'http') ? $displayText : Storage::disk('public')->url($displayText);

        return <<<HTML
<div class="d-inline">
    <audio controls >
        <source src="{$fileUrl}" type="audio/wav"/>
        <a href="{$fileUrl}">
            Download audio
        </a>
    </audio>
</div>
HTML;
    }
}
